#!/usr/bin/make -f

MODNAME=libapache2-mod-javascript

build:
	$(MAKE) CFLAGS=-O2 LDFLAGS=-s
clean:
	$(MAKE) clean
	rm -rf debian/files debian/substvars debian/tmp

binary: binary-arch binary-indep

binary-indep:

binary-arch: build
	rm -rf debian/tmp
	install -d debian/tmp debian/tmp/DEBIAN
	install -d debian/tmp/etc/apache2/mods-available
	install -d debian/tmp/usr/lib/apache2/modules
	install -d debian/tmp/usr/share/doc/$(MODNAME)
	strip --strip-unneeded -R .note -R .comment src/.libs/mod_javascript.so
	$(MAKE) PREFIX=$(CURDIR)/debian/tmp deb
	cp debian/changelog debian/tmp/usr/share/doc/$(MODNAME)/changelog.Debian
	cp changelog debian/tmp/usr/share/doc/$(MODNAME)/changelog
	cp README debian/tmp/usr/share/doc/$(MODNAME)
	cp debian/javascript.load debian/tmp/etc/apache2/mods-available/
	gzip -9 debian/tmp/usr/share/doc/$(MODNAME)/*
	cp debian/copyright debian/tmp/usr/share/doc/$(MODNAME)
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R o-s,go=u,go-ws debian/tmp
	chmod 644 debian/tmp/etc/apache2/mods-available/javascript.load
	chmod 644 debian/tmp/usr/lib/apache2/modules/mod_javascript.so
	dpkg --build debian/tmp ..


